package troopmanager.mooresr.us;

import java.sql.Date;

public class Person implements Comparable<Person> {
	private Integer personId;
	private String firstName;
	private String lastName;
	private Integer type;
	private Date medFormA;
	private Date medFormB;
	private Date medFormC;
	private String driversLicense;
	private Boolean active;
	private Date dob;
	private String cellPhone;
	private String homePhone;
	private String workPhone;
	private String gender;
	private String email;
	
	public static final Integer ADULT = 1;
	public static final Integer SCOUT = 2;
	
	public Person() {
		
	}
	
	public Person(Integer id, String firstName, String lastName, Integer type,
			Date medFormA, Date medFormB, Date medFormC, String driversLicense, Boolean active,
			Date dob, String cellPhone, String homePhone, String workPhone, String gender,
			String email) {
		super();
		this.personId = id;
		this.firstName = firstName;
		this.lastName = lastName;
		this.type = type;
		this.medFormA = medFormA;
		this.medFormB = medFormB;
		this.medFormC = medFormC;
		this.driversLicense = driversLicense;
		this.active = active;
		this.dob = dob;
		this.cellPhone = cellPhone;
		this.homePhone = homePhone;
		this.workPhone = workPhone;
		this.gender = gender;
		this.email = email;
	}




	public Integer getPersonId() {
		return personId;
	}
	public void setPersonId(Integer id) {
		this.personId = id;
	}
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public Date getMedFormA() {
		return medFormA;
	}
	public void setMedFormA(Date medFormA) {
		this.medFormA = medFormA;
	}
	public Date getMedFormB() {
		return medFormB;
	}
	public void setMedFormB(Date medFormB) {
		this.medFormB = medFormB;
	}
	public Date getMedFormC() {
		return medFormC;
	}
	public void setMedFormC(Date medFormC) {
		this.medFormC = medFormC;
	}
	public String getDriversLicense() {
		return driversLicense;
	}
	public void setDriversLicense(String driversLicense) {
		this.driversLicense = driversLicense;
	}
	
	public Date getDob() {
		return dob;
	}

	public void setDob(Date dob) {
		this.dob = dob;
	}

	public String getCellPhone() {
		return cellPhone;
	}

	public void setCellPhone(String cellPhone) {
		this.cellPhone = cellPhone;
	}

	public String getHomePhone() {
		return homePhone;
	}

	public void setHomePhone(String homePhone) {
		this.homePhone = homePhone;
	}

	public String getWorkPhone() {
		return workPhone;
	}

	public void setWorkPhone(String workPhone) {
		this.workPhone = workPhone;
	}
	
	public String getGender() {
		return gender;
	}
	
	public void setGender(String gender) {
		this.gender = gender;
	}

	public String toString() {
		return firstName + " " + lastName;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	@Override
	public int compareTo(Person o) {
		// Sort by name
		
		String fullName = new String(lastName+firstName);
		
		return fullName.compareTo(o.getLastName()+o.getFirstName()); 
	}
	
	public Integer getAge() {
		if (dob == null) {
			return 0;
		}
		
		Date today = new Date(System.currentTimeMillis());
		
		long todayLong = today.getTime();
		long dobLong = dob.getTime();
		
		long delta = todayLong - dobLong;
		
		long seconds = delta / 1000;
		long minutes = seconds / 60;
		long hours = minutes / 60;
		long days = hours / 24;
		long years = days / 365;
		
		return new Integer((int) years);
		
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	

}
